
<?php if (isset($orgs)) {  ?>

    <?php if((count($orgs)!=0)||(count($orgsIv)!=0)){ ?>
    
    <?php }?>
    <div>
        <a href="<?php echo $this->base;?>/organizations/add" class="btn btn-inverse pull-right"><i class="icon-plus-sign icon-white"></i> Nueva</a>
        <h1>Mis Organizaciones :  </h1>
        
    </div>
    <br/>
    <?php if((count($orgs)==0)&&(count($orgsIv)==0)){ ?>
        <div class="alert">
            <button type="button" class="close" data-dismiss="alert">×</button>
            <strong>Usted no cuenta con ninguna organización</strong>
        </div>
        <br/>
    <?php }  else {?>
        <div class="alert alert-info">
            <button type="button" class="close" data-dismiss="alert">×</button>
            <strong>Elija una organización de la lista.</strong>
        </div>
        <br/> 
    <?php   }?>
    
    <?php if(count($orgs)>0){ ?>
    
    <div class="row-fluid ">
        <div class="span12">
            <div class="span9">
             <h2>Creadas por mi:</h2>
<!--                <p><small>Created by:  <?php echo AuthComponent::user('username'); ?></small></p>-->
            </div>
            <div class="span3" align="right">
                
            </div>
        </div>
        
    
        <div class="span12">
            
                <?php foreach ($orgs as $org):
                if ($org['Organization']['active']) {?>
                <div class="row-fluid " style=" margin-bottom: 20px;  margin-top: 20px;">
                    <div class="span12">
                        <div class="span3">
                            <a href="#" class="thumbnail">
                                <img src="http://placehold.it/140x140" alt="">
                            </a>
                        </div>
                        <div class="span9">
                            <div class="caption">
                                <h3>
                                    <?php echo $this->Html->link($org['Organization']['name'],array('controller' => 'organizations', 'action' => 'view', $org['Organization']['id'])); ?>
                                </h3>
                                <p><small><?php echo $org['Organization']['created']; ?> </small></p>
                                <?php if (!$org['Organization']['active'])
                                    echo '<span class="label label-important">INACTIVA!</span>'; ?>
                                <p>
                                    <?php echo $org['Organization']['description']?>
                                
                                    <?php echo $this->Form->postLink(
                                        'Delete',
                                        array('action' => 'delete', $org['Organization']['id']),
                                        array('class' => 'btn btn-danger','confirm' => 'Are you sure?'));
                                    ?>
                                    <?php echo $this->Html->link('Edit', array('action' => 'edit', $org['Organization']['id']),array('class' => 'btn btn-primary')); ?>
                                 </p>       
                            </div>
                        </div>
                    </div>
                </div>
                <?php }
                endforeach; ?>
            
        </div>
    </div>

    
    <?php } ?>
    
    <?php if(count($orgsIv)>0){ ?>
    <div class="row-fluid ">
        <div class="span12">
            <div class="span9">
                <h1>Compartidas :  </h1>
            </div>
            <div class="span3" align="right">
                
            </div>
        </div>

    
        <div class="span12">
           
                <?php for($i=0;$i<count($orgsIv);$i++){
                        $org=$orgsIv[$i]; 
                if ($org['active']) {?>
                <div class="row-fluid " style=" margin-bottom: 20px;  margin-top: 20px;">
                    <div class="span12">
                        <div class="span3">
                            <a href="#" class="thumbnail">
                                <img src="http://placehold.it/140x140" alt="">
                            </a>
                        </div>
                        <div class="span9">
                            <div class="caption">
                                <h3>
                                    <?php echo $this->Html->link($org['name'],array('controller' => 'organizations', 'action' => 'view', $org['id'])); ?>
                                </h3>
                                <?php if (!$org['active'])
                                    echo '<span class="label label-important">INACTIVA!</span>'; ?>
                                <p><small><?php echo $org['created']; ?> </small></p>
                                <p>
                                    <?php echo $org['description']?>
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
                <?php } }?>
        </div>
    </div>

    <?php }?>



<?php } else {?>
    <br/>
    <div class="alert alert-info">
        Error de acceso.
    </div>
<?php }?>